﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MonoGame.Framework;
using Microsoft.Xna.Framework;
using TunnelsOfDeath.Objects;
using TunnelsOfDeath.Managers;

namespace TunnelsOfDeath
{
    static class Collisions
    {

        public static bool HandleCollision(Sprite _upper, Sprite _lower)
        {

            if (((_upper.Type == ObjectType.rock || _upper.Type == ObjectType.crystal) && _upper.ObjectDirection == Direction.down) && (_lower.Type == ObjectType.player || _lower.Type == ObjectType.enemy))
            {
                Globals.ObjectManager.GenerateExplosion(_lower.position, _upper.GetTag());
            }

            if (_upper.Type == ObjectType.player && _lower.Type == ObjectType.door)
            {
                Door door = (Door)_lower;
                Player player = (Player)_upper;

                if (Globals.MainPlayer.Scores >= door.GoldNeeded)
                {
                    System.Diagnostics.Debug.WriteLine("GOOD!");
                    player.State = PlayerState.FINISHED;
                    Globals.ObjectManager.UnregisterObject(player);
                }
            }

            //System.Diagnostics.Debug.WriteLine("Unhandled collision: " + _upper.Type.ToString() + " & " + _lower.Type.ToString());


            return false;
        }

    }
}
